from typing import *
from leetcode.editor.common.node import *


# leetcode submit region begin(Prohibit modification and deletion)
class Solution:
    def findMaxAverage(self, nums: List[int], k: int) -> float:
        ans = -10000
        vowel = 0
        for r, n in enumerate(nums):
            vowel += n

            left = r - k + 1
            # 窗口尚未形成
            if left < 0:
                continue

            ans = max(ans, vowel / k)
            vowel -= nums[left]
        return ans
        
# leetcode submit region end(Prohibit modification and deletion)


if __name__ == '__main__':
    solution = Solution()
    # your test code here